<%@ page contentType="text/html; charset=UTF-8"%>
<script language="JavaScript" src="${baseurl}JQuery/jquery-1.8.2.js"></script>
<script src="${baseurl}JS/loginjs/security .js" type="text/javascript"></script>
<script type="text/javascript" src="${baseurl}jQuery.easyui.1.2.2/js/jquery.easyui.min.js"></script>
<script src="${baseurl}JS/loginjs/cloud.js" type="text/javascript"></script>

<script language="JavaScript" type="text/javascript" charset="UTF-8">
//IE不支持console对象，此代码仅为测试使用
///////////////////////////////////////
window.console = window.console || (function () {  
    var c = {}; c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile  
    = c.clear = c.exception = c.trace = c.assert = function () { };  
    return c;  
})();  
var btnFlag = true;
//////////////////////////////////////
 $(function(){
	//用户输入栏位置设置
	$('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
	$(window).resize(function(){
	    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
    }) 
    //注册键盘事件
	document.onkeydown = function(e) {
	    //捕捉回车事件
	    var ev = (typeof event!= 'undefined') ? window.event : e;
	    if(ev.keyCode == 13) {
	    	dologin();
	    }
	}
	$("#login1").click(function(){
		 dologin();
	 	   
	}); 
});   
//重置验证码
function randomcode_refresh(){
	$("#randomcode_img").attr("src","${baseurl}images/kaptcha.jpg?"+ Math.random());
}
function dologin(){
	var win = $.messager.progress({
		title:'正在加载',
		msg:'请稍候...'
	});	
	//重置提示信息
    $("#unifo_login_span_id").text(" ");
	var epwd = $("#pwd_id").val();//用户输入密码
	var username=$("#user_id").val();
	if(username == "" || username == null ||epwd == "" || epwd == null){
    	$("#unifo_login_span_id").text("账户、密码必须填写");
    	$.messager.progress('close');
    	return;
    }
	var randomcode = $("#randomcode").val();
	
	if(randomcode == "" || randomcode == null ){
    	$("#unifo_login_span_id").text("验证码必须填写");
    	$.messager.progress('close');
    	return;
    }
	//校验非法字符
	var patrn=/[`~!@#$%^&*()_+<>?:"{},\/;'[\]]/;
	if(patrn.test(username)||patrn.test(epwd)){  
		$("#unifo_login_span_id").text("账户、密码非法字符");
		$.messager.progress('close');
		return true;     
	}
	//没有雪花，所以这样防止重复提交
	if(!btnFlag){
		$.messager.progress('close');
		return;
	}
	
	//var password=$("#pwd_id").val();
	        
   	//重置提示信息
    $("#unifo_login_span_id").text(" ");
    //用户是否点亮 记住密码按钮
    
    if(btnFlag){
   		btnFlag = false;
   	}else{
   		$.messager.progress('close');
   		return;
   	}
    var saveFlag = $("[name='rememberMe']").attr("checked")=="checked"?true:false;
    $("[name='rememberMe']").attr("value",saveFlag);
    $("#loginform").submit();
    $.messager.progress('close');
    return;
	
}	
/* function getCookie(cookieName) {
    var strCookie = document.cookie;
    var arrCookie = strCookie.split("; ");
    for(var i = 0; i < arrCookie.length; i++){
        var arr = arrCookie[i].split("=");
        if(cookieName == arr[0]){
            return arr[1];
        }
    }
    return "";
}	 */
</script> 